// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package base

// TraceId
// is a component of a trace.
type TraceId struct {
	b []byte
	s string
}

// NewTraceId
// creates a new trace id.
func NewTraceId() *TraceId {
	o := &TraceId{}
	o.b = gen.make(16)
	o.s = gen.convert(o.b)
	return o
}

// NewTraceIdWithHex
// creates a new trace id with hex string.
func NewTraceIdWithHex(s string) *TraceId {
	o := &TraceId{s: s}
	o.b = gen.decode(s)
	return o
}

// Byte
// returns the trace id as a byte array.
func (o *TraceId) Byte() []byte {
	return o.b
}

// String
// returns the trace id as a string.
func (o *TraceId) String() string {
	return o.s
}
